import 'package:flutter/material.dart';
import 'package:event_bus/event_bus.dart';
import 'package:flutter_study/eventbus/bean.dart';
import 'package:flutter_study/eventbus/eventbus.dart';
import 'package:uuid/uuid.dart';
class SendData extends StatefulWidget {
  final String title;

  SendData({Key key, this.title}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return SendDataState();
  }
}

class SendDataState extends State<SendData> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text(this.widget.title),
      ),
      body: Column(
        children: <Widget>[
          RaisedButton(
            onPressed: () {
              _sendDate();
            },
            child: Text('发送数据：使用eventbus'),
          ),
        ],
      ),
    );
  }

  void _sendDate() {
    var uuid = new Uuid();
    EventBusBean bean = EventBusBean('收到数据', '来自eventbus消息${uuid.v1()}');
    eventBus.fire(bean);
    Navigator.of(context).pop();
  }
}
